package battle.commands
{
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public class CommandQueue extends EventDispatcher
	{
		public function CommandQueue()
		{
			
		}
		
		
		private static var _instance:CommandQueue;
		public static function get Instance():CommandQueue
		{
			if(_instance == null)
			{
				_instance = new CommandQueue();
			}
			return _instance;
		}
		
		public function excute():void
		{
			if(_commands.length == 0)return;
			if(_commands[0].isFinish)
			{
				_commands.shift();
				return;
			}
			_commands[0].excute();
		}
		
		private var _commands:Vector.<Command> = new Vector.<Command>();
		public function addCommand(cm:Command):void
		{
			cm.prepare();
			_commands.push(cm);
		}
		
		public function excuteImp():void
		{
			
		}
		
		public function removeCommand(cm:Command):void
		{
			_commands.splice(_commands.indexOf(cm),1);
		}
		
		
	}
}